<script setup lang='ts'>
import { onMounted, ref } from 'vue';

const aDom = ref(null) //1.创建ref对象
const bDom = ref(null) //1.创建ref对象

onMounted(() => {
    if(aDom.value){
        const dom = aDom.value as HTMLAnchorElement
        dom.href = 'https://www.bilibili.com'
    }
    if(bDom.value){
        const dom = bDom.value as HTMLButtonElement
        dom.onclick = () => {
        alert("这是脱裤子放屁的一种写法")
      }
    }
})

</script>

<template>
    <div>
        <h1>获取a标签的dom对象</h1>
        <!-- 2.绑定对象 -->
        <a ref="aDom" style="margin: 0 20px;" href="https://www.baidu.com">百度</a>
        <button ref="bDom" >button的按钮</button>
    </div>

</template>

<style scoped></style>